<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>
 
<s:layout-render name="/menu.jsp" nadpis="Lector">
    <s:layout-component name="telo">
    <s:useActionBean beanclass="com.pa165.languageschoolpresentation.LectorActionBean" var="actionBean"/>
   <f:message key="Total"/> = ${actionBean.lectors.size()}:
        <table class="table">
            <tr>
                <th><f:message key="Number"/></th>
                <th><f:message key="Id"/></th>
                <th><f:message key="lector.name"/></th>
                <th><f:message key="lector.surname"/></th>
                <th><f:message key="lector.languages"/></th>
                <c:if test="${pageContext.request.isUserInRole('ROLE_ADMIN')}" >
                <th></th>
                <th></th>
                <th></th>
                 </c:if>
            </tr>
            <c:forEach items="${actionBean.lectors}" var="lectorDTO" varStatus="loop">
                <tr>
                    <td>${loop.index + 1}</td>
                    <td>${lectorDTO.id}</td>                   
                    <td><c:out value="${lectorDTO.name}"/></td> 
                    <td><c:out value="${lectorDTO.surname}"/></td> 
                    <td><c:forEach items="${actionBean.levelOfLanguageService.getByLector(lectorDTO)}" var="levelOfLanguageDTO">
                         <f:message key="com.pa165.languageschoolpersistence.entities.LanguageSpoken.${levelOfLanguageDTO.languageSpoken}"/> -
                         <f:message key="com.pa165.languageschoolpersistence.entities.LanguageLevel.${levelOfLanguageDTO.level}"/> <br/>
                         </c:forEach>
                    </td> 
                    <c:if test="${pageContext.request.isUserInRole('ROLE_ADMIN')}" >
                    <td><s:link beanclass="com.pa165.languageschoolpresentation.LectorActionBean" event="delete"><s:param name="lectorDTO.id" value="${lectorDTO.id}"/><f:message key="Delete"/></s:link> </td>
                    <td><s:link beanclass="com.pa165.languageschoolpresentation.LectorActionBean" event="edit"><s:param name="lectorDTO.id" value="${lectorDTO.id}"/><f:message key="Edit"/></s:link> </td>
                    <td><s:link beanclass="com.pa165.languageschoolpresentation.LectorActionBean" event="showLectures"><s:param name="lectorDTO.id" value="${lectorDTO.id}"/><f:message key="ManageLectures"/></s:link> </td>
                    </c:if>
                </tr>
            </c:forEach>
        </table>
       <c:if test="${pageContext.request.isUserInRole('ROLE_ADMIN')}" >
        <s:link beanclass="com.pa165.languageschoolpresentation.LectorActionBean" event="add"><f:message key="Add"/></s:link> 
       </c:if>
    </s:layout-component>
</s:layout-render>
